package cn.org.timespace.ons.infrastructure.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.support.WebApplicationContextUtils;

import cn.org.timespace.ons.util.SystemContext;

public class InitiationServletContextLoaderListener implements ServletContextListener {
	private static final Log log = LogFactory.getLog(InitiationServletContextLoaderListener.class);

	public void contextDestroyed(ServletContextEvent event) {
	}

	public void contextInitialized(ServletContextEvent event) {
		log.debug("应用起始初始化");
		ServletContext servletContext = event.getServletContext();
		SystemContext.setApplicationContext(WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext));
	}
}